// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------
// Modification history:
// feature: discovery support client and server
// ------------------------------------------------------------------

#ifndef INCLUDE_EDDS_RTPS_COMMON_TYPES_H_
#define INCLUDE_EDDS_RTPS_COMMON_TYPES_H_

#include <stddef.h>
#include <iostream>
#include <cstdint>
#include <stdint.h>

#include <ertps/ertps_dll.h>

#include <edds/rtps/common/VendorId_t.hpp>
#include <edds/rtps/common/Version_t.hpp>

#include <deps/common/Types.h>

namespace evbs {
namespace ertps {
namespace rtps {

/*!
 * @brief This enumeration represents endianness types.
 * @ingroup COMMON_MODULE
 */
enum Endianness_t {
    //! @brief Big endianness.
    BIGEND = 0x1U,
    //! @brief Little endianness.
    LITTLEEND = 0x0U
};

using ReliabilityKind_t = vbsutil::xmlparser::ReliabilityKind_t;
using vbsutil::xmlparser::ReliabilityKind_t::BEST_EFFORT;
using vbsutil::xmlparser::ReliabilityKind_t::RELIABLE;

using DurabilityKind_t = vbsutil::xmlparser::DurabilityKind_t;
using vbsutil::xmlparser::DurabilityKind_t::PERSISTENT;
using vbsutil::xmlparser::DurabilityKind_t::TRANSIENT;
using vbsutil::xmlparser::DurabilityKind_t::TRANSIENT_LOCAL;
using vbsutil::xmlparser::DurabilityKind_t::VOLATILE;

using EndpointKind_t = vbsutil::xmlparser::EndpointKind_t;
using vbsutil::xmlparser::EndpointKind_t::READER;
using vbsutil::xmlparser::EndpointKind_t::WRITER;

using TopicKind_t = vbsutil::xmlparser::TopicKind_t;
using vbsutil::xmlparser::TopicKind_t::NO_KEY;
using vbsutil::xmlparser::TopicKind_t::WITH_KEY;

using TransportTypeKind = vbsutil::xmlparser::TransportTypeKind;
using vbsutil::xmlparser::TransportTypeKind::TRANSPORT_TYPE_ALL;
using vbsutil::xmlparser::TransportTypeKind::TRANSPORT_TYPE_AUTO;
using vbsutil::xmlparser::TransportTypeKind::TRANSPORT_TYPE_SHM;
using vbsutil::xmlparser::TransportTypeKind::TRANSPORT_TYPE_UDP;

#if EDDS_IS_BIG_ENDIAN_TARGET
constexpr Endianness_t DEFAULT_ENDIAN = BIGEND;
#else
constexpr Endianness_t DEFAULT_ENDIAN = LITTLEEND;
#endif  // if EDDS_IS_BIG_ENDIAN_TARGET

using octet = unsigned char;
using SubmessageFlag = unsigned char;
using BuiltinEndpointSet_t = uint32_t;
using NetworkConfigSet_t = uint32_t;
using Count_t = uint32_t;

#define BIT0 0x01U
#define BIT1 0x02U
#define BIT2 0x04U
#define BIT3 0x08U
#define BIT4 0x10U
#define BIT5 0x20U
#define BIT6 0x40U
#define BIT7 0x80U

#define BIT(i) (1U << static_cast<unsigned>(i))

using ProtocolVersion_t = vbsutil::xmlparser::ProtocolVersion_t;
using vbsutil::xmlparser::c_ProtocolVersion;
using vbsutil::xmlparser::c_ProtocolVersion_2_0;
using vbsutil::xmlparser::c_ProtocolVersion_2_1;
using vbsutil::xmlparser::c_ProtocolVersion_2_2;
using vbsutil::xmlparser::c_ProtocolVersion_2_3;
using vbsutil::xmlparser::operator<<;

//!@brief Structure VendorId_t, specifying the vendor Id of the implementation.
using VendorId_t = evbs::edds::rtps::VendorId_t;
using EvbsVersion_t = evbs::edds::rtps::EvbsVersion_t;
using evbs::edds::rtps::c_VendorId_Unknown;
using evbs::edds::rtps::c_VendorId_vbs;
using evbs::edds::rtps::c_Version_vbs;

}  // namespace rtps
}  // namespace ertps
}  // namespace evbs

#endif  // INCLUDE_EDDS_RTPS_COMMON_TYPES_H_
